#!/usr/bin/env python
import sys
import helper
import class_set
from sets import Set

class ResourceRecommendationReducer(helper.ReducerHelper):
    """
    Rsesult:
    A <- B \t resource:addtime_A:aid
    B <- A \t resource:addtime_B:aid
    """
    def processor(self, key, lst):
        for e in lst:
            for m in lst:
                eleft, eright = self.split(e)
                mleft, mright = self.split(m)
                if eleft != mleft:
                    recom_tag = class_set.RecomTag('')
                    #TODO time here maybe have some problem, for right_i not the same with right_j
                    recom_tag.init(eright)
                    self.allocator(self.join(eleft, mleft), recom_tag)

def main():
    rr = ResourceRecommendationReducer()
    rr.reducer()

if __name__ == '__main__':
    main()

